package com.aw.guiguzi.bean

import com.aw.guiguzi.util.AppCacheUtil

class NumItemBean {
    var name: String
    var multiple: Float
    var isChecked = false
    private var silverCount = 0
    private var skinCount = 0
    private var gemstoneCount = 0
    private var isDouble = false
    var numList: List<Int>? = null
    fun is10(): Boolean {
        return multiple == 10f
    }

    fun is5(): Boolean {
        return multiple == 5f
    }

    fun is2Point5(): Boolean {
        return multiple.toDouble() == 2.5
    }

    fun is2(): Boolean {
        return multiple == 2f
    }

    fun isAllowDouble(): Boolean {
        return is2() || skinCount <= 5 && silverCount <= 5 && gemstoneCount <= 100
    }

    constructor(name: String, multiple: Float, numList: List<Int>?) {
        this.name = name
        this.multiple = multiple
        this.numList = numList
        if (multiple == 10f) {
            isDouble = false
        } else if (multiple == 5f) {
            isDouble = AppCacheUtil.isBettingConfigDouble5()
        } else if (multiple == 2.5f) {
            isDouble = AppCacheUtil.getBettingConfigDouble2Half5()
        } else if (multiple == 2f) {
            isDouble = AppCacheUtil.isBettingConfigDouble2()
        }
    }

    constructor(name: String, multiple: Float, isChecked: Boolean) {
        this.name = name
        this.multiple = multiple
        this.isChecked = isChecked
    }

    fun getSilverCount(): Int {
        return if (isDouble && (is2() || silverCount <= 5)) {
            silverCount * 2
        } else silverCount
    }

    fun setSilverCount(silverCount: Int) {
        this.silverCount = silverCount
    }

    fun getSkinCount(): Int {
        return if (isDouble && (is2() || skinCount <= 5)) {
            skinCount * 2
        } else skinCount
    }

    fun setSkinCount(skinCount: Int) {
        this.skinCount = skinCount
    }

    fun getGemstoneCount(): Int {
        return if (isDouble && (is2() || gemstoneCount <= 100)) {
            gemstoneCount * 2
        } else gemstoneCount
    }

    fun setGemstoneCount(gemstoneCount: Int) {
        this.gemstoneCount = gemstoneCount
    }

    fun isDouble(): Boolean {
        if (!isAllowDouble()) {
            isDouble = false
        }
        return isDouble
    }

    fun setDouble(aDouble: Boolean) {
        if (isAllowDouble()) {
            isDouble = aDouble
        }
    }
}